ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Hare_Juvenile Class Reference

Class for juvenile hares (after 5 weeks old, fully mobile) More...

#include <hare_all.h>

Inheritance diagram for Hare_Juvenile:
THare TAnimal TALMaSSObject Hare_Female Hare_Male

Public Member Functions

virtual void BeginStep (void)
 BeginStep for Hare_Juvenile. More...
 
virtual void Step (void)
 Step for Hare_Juvenile. More...
 
virtual void EndStep (void)
 BeginStep for Hare_Juvenile. More...
 
 Hare_Juvenile (int p_x, int p_y, Landscape *p_L, THare_Population_Manager *p_PPM, double p_weight)
 Constructor for the juvenile hare object. More...
 
void ReInit (struct_Hare a_data)
 Juvenile object reinitiation. More...
 
void Init (double p_weight)
 Object initiation. More...
 
virtual ~Hare_Juvenile ()
 Destructor for the juvenile hare object. More...
 
virtual void ON_Dead ()
 
- Public Member Functions inherited from THare
 THare (int p_x, int p_y, Landscape *p_L, THare_Population_Manager *p_PPM)
 Constructor. More...
 
void THareInit (int p_x, int p_y, THare_Population_Manager *p_PPM)
 Object Initiation. More...
 
virtual ~THare ()
 Destructor. More...
 
double GetWeight ()
 
double GetTotalWeight ()
 Provide the wet weight of the hare. More...
 
int GetAge ()
 
void ON_MumDead (Hare_Female *a_Mum)
 Inform Mum that we are dead. More...
 
void SetMum (Hare_Female *)
 Set the mother pointer. Reimplemented in Hare_Infant. More...
 
Hare_FemaleGetMum ()
 Get the mother pointer. More...
 
double GetRMR ()
 Get todays RMR. More...
 
int GetRefNum ()
 Get the refnum for this hare. More...
 
void loadVegPalatability (void)
 Loads static member m_vegPalatability with data. More...
 
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
 
AnimalPosition SupplyPosition ()
 
APoint SupplyPoint ()
 
int SupplyPolygonRef ()
 
int Supply_m_Location_x ()
 
int Supply_m_Location_y ()
 
virtual void KillThis ()
 
virtual void CopyMyself ()
 
void SetX (int a_x)
 
void SetY (int a_y)
 
 TAnimal (int x, int y, Landscape *L)
 
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual int WhatState ()
 
virtual void Dying ()
 
void CheckManagement (void)
 
void CheckManagementXY (int x, int y)
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone ()
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
 
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 

Protected Member Functions

TTypeOfHareState st_Developing ()
 The development code for Hare_Juvenile. More...
 
TTypeOfHareState st_Dispersal ()
 Juvenile Dispersal. More...
 
TTypeOfHareState st_Foraging ()
 Juvenile foraging. More...
 
void st_NextStage ()
 Maturation to Hare_Male or Hare_Female. More...
 
TTypeOfHareState st_Resting ()
 Juvenile Resting. More...
 
bool ShouldMature ()
 Test for maturation. More...
 
virtual bool WasPredated ()
 Test for mortality. More...
 
- Protected Member Functions inherited from THare
bool Run (int a_dist, int a_direction)
 Run a distance in a direction. More...
 
void EnergyBalance (TTypeOfActivity a_activity, int dist)
 Adjust energy balance for an activity. More...
 
void TimeBudget (TTypeOfActivity a_activity, int dist)
 Adjust time budger for an activity. More...
 
void st_Dying ()
 Tidy up before removing the object on death. More...
 
virtual void Running (int a_max_dist)
 Run. More...
 
void Walking (int a_dist, int a_direction)
 Walking. More...
 
double Forage (int &time)
 Foraging. More...
 
double ForageP (int &time)
 Foraging but also incorporating pesticide exposure. More...
 
virtual void InternalPesticideHandlingAndResponse ()
 Handles internal effects of pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes. More...
 
virtual void GeneralEndocrineDisruptor (double)
 Handles internal effects of endocrine distrupter pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes. More...
 
virtual void GeneralOrganoPhosphate (double)
 Handles internal effects of organophosphate pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes. More...
 
double ForageSquare (int a_x, int a_y)
 Forage from an area. More...
 
double ForageSquareP (int a_x, int a_y, double *a_pestexposure)
 Forage from an area and resturn pesticide exposure as well as food. More...
 
int GetPegDistance ()
 Get peg distance. More...
 
int GetPegPull ()
 Get attractive force of peg. More...
 
int GetPegDirection ()
 Get direction of peg. More...
 
void MovePeg ()
 Move the peg according to attraction forces. More...
 
bool OnFarmEvent (FarmToDo event)
 Do we require a response to a farm event. More...
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 

Additional Inherited Members

- Static Public Attributes inherited from THare
static double * m_vegPalatability = NULL
 Will hold and array of palatability for hare for each tov type. Most are 1, but unpalatable vegetation can be specified here. More...
 
- Protected Attributes inherited from THare
TTypeOfHareState m_CurrentHState
 Defines the current activity. More...
 
int m_Age
 State variale - hare age. More...
 
Hare_Object m_Type
 State variale - the type of hare. More...
 
double m_weight
 State variale - hare weight g. More...
 
double m_old_weight
 State variale - last hare weight. More...
 
Hare_Femalem_MyMum
 Pointer to the hare's mum. More...
 
THare_Population_Managerm_OurPopulationManager
 Pointer to the hare population manager. More...
 
int m_Lifespan
 Physiolocal lifespan, assuming nothing else kills the hare (unlikely to reach this age) More...
 
int m_ActivityTime
 Minutes of potential activity time per day. More...
 
int m_StarvationDays
 State variable - the number of consecutive days in negative energy balance. More...
 
double m_fatReserve
 State variable - the energy reserve of the hare. More...
 
double m_TodaysEnergy
 State variable - the amount of energy available today, can be in deficit. More...
 
double m_EnergyMax
 State variable - the amount of energy it is possible to eat as a multiplyer or RMR. More...
 
double m_KJRunning
 KJ/m cost of running per kg hare. More...
 
double m_KJWalking
 KJ/m cost of walking per kg hare. More...
 
double m_KJForaging
 KJ/m cost of foraging per kg hare. More...
 
double m_SpeedRunning
 m/min speed of running per kg hare More...
 
double m_SpeedWalking
 m/min speed of walking per kg hare More...
 
double m_foragingenergy
 Energy obtained from foraging/feeding. More...
 
int m_peg_x
 peg x-coordinate More...
 
int m_peg_y
 peg y-coordinate More...
 
int m_RefNum
 Unique hare reference number, also functions as sex flag. More...
 
int m_experiencedDensity
 State variable used in alternative density-dependent configurations. More...
 
int m_lastYearsDensity
 State variable used in alternative density-dependent configurations. More...
 
int m_ddindex
 State variable used in alternative density-dependent configurations. More...
 
int m_expDensity [365]
 State variable used in alternative density-dependent configurations. More...
 
int m_DensitySum
 State variable used in alternative density-dependent configurations. More...
 
bool m_IamSick
 flag for sickness - used in conjunction with disease configurations More...
 
double m_pesticide_burden
 State variable used to hold the current body-burden of pesticide. More...
 
double m_pesticidedegradationrate
 State variable used to hold the daily degredation rate of the pesticide in the body. More...
 
bool m_pesticideInfluenced1
 Flag to indicate pesticide effects (e.g. can be used for endocrine distruptors with delayed effects until birth). More...
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 
int m_Location_y
 
Landscapem_OurLandscape
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Detailed Description

Class for juvenile hares (after 5 weeks old, fully mobile)

Constructor & Destructor Documentation

◆ Hare_Juvenile()

Hare_Juvenile::Hare_Juvenile ( int  p_x,
int  p_y,
Landscape p_L,
THare_Population_Manager p_PPM,
double  p_weight 
)

Constructor for the juvenile hare object.

2221  : THare(p_x,p_y,p_L,p_PPM)
2222 {
2223  Init(p_weight);
2224 }
void Init(double p_weight)
Object initiation.
Definition: Hare_all.cpp:2236
THare(int p_x, int p_y, Landscape *p_L, THare_Population_Manager *p_PPM)
Constructor.
Definition: Hare_THare.cpp:66

References Init().

◆ ~Hare_Juvenile()

Hare_Juvenile::~Hare_Juvenile ( )
virtual

Destructor for the juvenile hare object.

2248 {
2249  //Nothing to do
2250 }

Member Function Documentation

◆ BeginStep()

void Hare_Juvenile::BeginStep ( void  )
virtual

BeginStep for Hare_Juvenile.

Resets the day's activity counter and checks for default mortalities and potentially extra mortalities. Calculates energy usage for movement based on todays weight

Reimplemented from THare.

Reimplemented in Hare_Female, and Hare_Male.

2262 {
2263  if (m_CurrentStateNo == -1) return;
2264  m_ActivityTime=1440; // Start the day
2265  m_old_weight=m_weight-1; // we are not interested in tiny fluctuations
2269 
2270 #ifdef __DDEPMORT
2272 #ifdef __THRESHOLD_DD
2273  if (dens<m_OurPopulationManager->m_HareThresholdDD) dens=0;
2275 #endif
2276  double inter=m_OurPopulationManager->GetInterference(dens);
2277  if (g_rand_uni() > inter) {
2278  ON_Dead();
2279  m_StepDone=true; // We need to skip the step code, we are dead
2280  return;
2281  }
2282 #endif
2283 
2285  ON_Dead();
2286  m_StepDone=true; // We need to skip the step code, we are dead
2287  return;
2288  }
2289 
2292  }
2293 #ifdef __DISEASEDDM3
2294  m_ddindex++;
2295  if (m_ddindex==365) {
2296  m_ddindex=0;
2297  }
2301  m_lastYearsDensity= int(m_DensitySum * (1.0/365.0));
2302 #endif
2303  // Set the maximum possible energy intake
2305  CheckManagement();
2306 }
static CfgFloat cfg_MaxEnergyIntakeScaler("HARE_MAXENERGYINTAKESCALER", CFG_CUSTOM, 3.0)
static CfgFloat cfg_hare_proximity_alert("HARE_PROXIMITY_ALERT", CFG_CUSTOM, 0.05)
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
CfgInt cfg_hare_escape_dist("HARE_ESCAPE_DIST", CFG_CUSTOM, 100)
double value(void)
Definition: configurator.h:118
int value(void)
Definition: configurator.h:98
virtual void ON_Dead()
Definition: Hare_all.cpp:2654
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: PopulationManager.h:118
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: PopulationManager.h:116
int m_Location_y
Definition: PopulationManager.h:228
int m_Location_x
Definition: PopulationManager.h:225
void CheckManagement(void)
Definition: PopulationManager.cpp:1404
double m_JuvMortRate
Input variable - Juvenile mortality rate.
Definition: hare_all.h:730
int GetTotalDensity(int x, int y)
Density function - returns the density of all hares in the square containing by x,...
Definition: hare_all.h:676
double GetKJperM(int a_size)
Get the cost of moving 1m in KJ dependent upon mass (.
Definition: hare_all.h:626
int m_HareThresholdDD
Input variable - Threshold density dependence level.
Definition: hare_all.h:750
double GetInterference(int h)
Return the proportion of time used in communicating with con-specifics.
Definition: hare_all.h:700
virtual void Running(int a_max_dist)
Run.
Definition: Hare_THare.cpp:152
int m_ddindex
State variable used in alternative density-dependent configurations.
Definition: hare_all.h:281
double m_KJForaging
KJ/m cost of foraging per kg hare.
Definition: hare_all.h:238
double m_old_weight
State variale - last hare weight.
Definition: hare_all.h:185
double GetRMR()
Get todays RMR.
Definition: Hare_THare.cpp:349
int m_ActivityTime
Minutes of potential activity time per day.
Definition: hare_all.h:203
int m_DensitySum
State variable used in alternative density-dependent configurations.
Definition: hare_all.h:291
double m_EnergyMax
State variable - the amount of energy it is possible to eat as a multiplyer or RMR.
Definition: hare_all.h:223
double m_KJWalking
KJ/m cost of walking per kg hare.
Definition: hare_all.h:233
int m_lastYearsDensity
State variable used in alternative density-dependent configurations.
Definition: hare_all.h:276
int m_expDensity[365]
State variable used in alternative density-dependent configurations.
Definition: hare_all.h:286
double m_weight
State variale - hare weight g.
Definition: hare_all.h:180
double m_KJRunning
KJ/m cost of running per kg hare.
Definition: hare_all.h:228
THare_Population_Manager * m_OurPopulationManager
Pointer to the hare population manager.
Definition: hare_all.h:194

References cfg_hare_escape_dist, cfg_hare_proximity_alert, cfg_MaxEnergyIntakeScaler, TAnimal::CheckManagement(), g_rand_uni, THare_Population_Manager::GetInterference(), THare_Population_Manager::GetKJperM(), THare::GetRMR(), THare_Population_Manager::GetTotalDensity(), THare::m_ActivityTime, TALMaSSObject::m_CurrentStateNo, THare::m_ddindex, THare::m_DensitySum, THare::m_EnergyMax, THare::m_expDensity, THare_Population_Manager::m_HareThresholdDD, THare_Population_Manager::m_JuvMortRate, THare::m_KJForaging, THare::m_KJRunning, THare::m_KJWalking, THare::m_lastYearsDensity, TAnimal::m_Location_x, TAnimal::m_Location_y, THare::m_old_weight, THare::m_OurPopulationManager, TALMaSSObject::m_StepDone, THare::m_weight, ON_Dead(), THare::Running(), CfgInt::value(), and CfgFloat::value().

◆ EndStep()

void Hare_Juvenile::EndStep ( void  )
virtual

BeginStep for Hare_Juvenile.

Just moves the homerange centre peg closer to where the hare has been active today

Reimplemented from THare.

Reimplemented in Hare_Female, and Hare_Male.

2380 {
2381  MovePeg();
2383 }
CfgBool cfg_hare_pesticideresponse_on("HARE_PESTICIDERESPONSE_ON", CFG_CUSTOM, false)
If set to true then hares will collect and respond to pesticide information. This will slow the simul...
bool value(void)
Definition: configurator.h:135
virtual void InternalPesticideHandlingAndResponse()
Handles internal effects of pesticide exposure. If any effects are needed this method must be re-impl...
Definition: HareForagenPeg.cpp:551
void MovePeg()
Move the peg according to attraction forces.
Definition: HareForagenPeg.cpp:527

References cfg_hare_pesticideresponse_on, THare::InternalPesticideHandlingAndResponse(), THare::MovePeg(), and CfgBool::value().

◆ Init()

void Hare_Juvenile::Init ( double  p_weight)

Object initiation.

2237 {
2238  m_Type = hob_Juvenile;
2239  m_weight = p_weight;
2240  m_Age = 35; // By definition we are 35 days old today
2241 }
Hare_Object m_Type
State variale - the type of hare.
Definition: hare_all.h:175
int m_Age
State variale - hare age.
Definition: hare_all.h:170
@ hob_Juvenile
Definition: hare_all.h:59

References hob_Juvenile, THare::m_Age, THare::m_Type, and THare::m_weight.

Referenced by Hare_Juvenile(), and ReInit().

◆ ON_Dead()

void Hare_Juvenile::ON_Dead ( void  )
virtual

Do the housekeeping necessary for removal of the object - in this case minimal.

Reimplemented from THare.

Reimplemented in Hare_Female, and Hare_Male.

2655 {
2657  m_CurrentStateNo=-1;
2658  m_StepDone=true;
2659 }
TTypeOfHareState m_CurrentHState
Defines the current activity.
Definition: hare_all.h:165
@ tohs_DestroyObject
Definition: hare_all.h:80

References THare::m_CurrentHState, TALMaSSObject::m_CurrentStateNo, TALMaSSObject::m_StepDone, and tohs_DestroyObject.

Referenced by BeginStep(), THare_Population_Manager::Hunting(), THare_Population_Manager::HuntingGrid(), and Step().

◆ ReInit()

void Hare_Juvenile::ReInit ( struct_Hare  a_data)

Juvenile object reinitiation.

2226 {
2227  m_Location_x = a_data.x;
2228  m_Location_y = a_data.y;
2229  m_OurLandscape = a_data.L;
2230  m_CurrentStateNo = 0;
2231  THareInit(a_data.x, a_data.y, a_data.HM);
2232  Init(a_data.weight);
2233 }
Landscape * m_OurLandscape
Definition: PopulationManager.h:229
void THareInit(int p_x, int p_y, THare_Population_Manager *p_PPM)
Object Initiation.
Definition: Hare_THare.cpp:72
int y
Definition: hare_all.h:138
int x
Definition: hare_all.h:137
Landscape * L
Definition: hare_all.h:140
double weight
Definition: hare_all.h:144
THare_Population_Manager * HM
Definition: hare_all.h:141

References struct_Hare::HM, Init(), struct_Hare::L, TALMaSSObject::m_CurrentStateNo, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, THare::THareInit(), struct_Hare::weight, struct_Hare::x, and struct_Hare::y.

Referenced by THare_Population_Manager::CreateObjects().

◆ ShouldMature()

bool Hare_Juvenile::ShouldMature ( )
protected

Test for maturation.

This method will be used to determine whether the hare becomes sexually active - and therefore needs to become an adult hare.

2631 {
2636  if (++m_Age<180) return false;
2637  // Do not do it below six months
2638  // If 6mths old and it is before October, then can mature
2639  if (m_OurLandscape->SupplyDayInYear() < 270) return true;
2640  if (m_Age>364) return true;
2641  return true;
2642 }
int SupplyDayInYear(void)
Definition: landscape.h:1596

References THare::m_Age, TAnimal::m_OurLandscape, and Landscape::SupplyDayInYear().

Referenced by st_Developing().

◆ st_Developing()

TTypeOfHareState Hare_Juvenile::st_Developing ( )
protected

The development code for Hare_Juvenile.

Tests for the onset of maturation. Also tests for minimum growth attainment if this is switched on - too low growth results in death.

Assumes that the fatReserve has been added to by st_Foraging from yesterday.
This is the last behaviour state called each day, so we can use this to sort out the energetics.

2523 {
2524  // Test for the onset of reproductive activity
2525  // This should be done now because otherwise it is possible to skip this test and get too old
2526  if (ShouldMature()) {
2527  return tohs_NextStage;
2528  }
2529 #ifdef __MINGROWTHATTAIN
2530  // Take a check on our growth - if we are below X% of the min repro weight, assume we died
2531  //if (m_weight < (cfg_hare_minimum_breeding_weight.value()*cfg_min_growth_attain.value())) return tohs_Dying;
2532  if (m_weight< m_OurPopulationManager->m_DMWeight[m_Age]) {
2533  return tohs_Dying;
2534  }
2535 #endif
2536 
2543  if (m_TodaysEnergy<Target) Target=m_TodaysEnergy;
2544  double addedtoday=Target*m_OurPopulationManager->GetGrowthEfficiencyP(m_Age);
2545  m_weight+=addedtoday;
2546  m_TodaysEnergy-=Target;
2548  if (m_TodaysEnergy<Target) Target=m_TodaysEnergy;
2550  m_weight+=addedtoday;
2551  m_TodaysEnergy-=Target;
2552  if (m_TodaysEnergy>0) {
2553  // Put what remains back into fat reserve
2554  m_fatReserve+=m_TodaysEnergy*m_OurPopulationManager->GetGrowthEfficiencyF(366); // 366 is the fat conversion efficiency
2555  m_TodaysEnergy=0;
2556  // Cap the fat reserve and store surplus energy for today
2559  }
2560  m_StarvationDays=0; // Not starving
2561  return tohs_Foraging;
2562  }
2563  else {
2564  m_fatReserve+=m_TodaysEnergy*m_OurPopulationManager->GetGrowthEfficiencyF(366); // 366 is the fat conversion efficiency
2565  if (m_fatReserve<0) {
2567  m_fatReserve=0.0;
2568  }
2569  else m_TodaysEnergy=0;
2570  // What should the criteria for a starvation day be? Here chosen to be any negative energy balance.
2571  // Have also considered and rejected a proportion of rmr:
2572  //double rmr=m_OurPopulationManager->GetRMR(m_Age, GetTotalWeight());
2573 // if (m_TodaysEnergy<(0.0-(rmr*0.25)))
2574  if (m_TodaysEnergy<0.0)
2575  {
2576 #ifndef __NOJUVSTARVE
2577  // Oh oh, we are starving need to lose body weight and maybe we will die?
2578 #ifdef __ADULT_WT_STARVE_CHANCE
2580  if ((g_rand_uni() * 10000) > (cfg_juv_starve.value()))
2581  {
2582  return tohs_Dying;
2583  }
2584  }
2585 #else
2587  return tohs_Dying;
2588  }
2589 #endif
2590 #endif
2591  }
2592  else {
2593  m_StarvationDays--; // Not starving
2595  m_TodaysEnergy=0;
2596  }
2597  }
2598  return tohs_Foraging;
2599 
2600 }
static CfgFloat cfg_AdultMaxFat("HARE_ADULT_MAXFAT", CFG_CUSTOM, 0.04/(0.33 *0.88))
static CfgInt cfg_juvenile_starvation_threshold("HARE_JUVENILE_STARVE_THRESHOLD", CFG_CUSTOM, 16)
CfgInt cfg_juv_starve("HARE_JUV_STARVE", CFG_CUSTOM, 2500)
bool ShouldMature()
Test for maturation.
Definition: Hare_all.cpp:2630
double GetGrowthEfficiencyP(int a_age)
Get the growth efficiency for this a_age for creating protein.
Definition: hare_all.h:602
double GetMaxDailyGrowthEnergyF(int a_age)
Get the maximum daily energy needed for growth for this a_age for use in fat construction.
Definition: hare_all.h:578
double GetMaxDailyGrowthEnergyP(int a_age)
Get the maximum daily energy needed for growth for this a_age for use in protein construction.
Definition: hare_all.h:565
double GetGrowthEfficiencyF(int a_age)
Get the growth efficiency for this a_age for creating fat.
Definition: hare_all.h:614
double m_fatReserve
State variable - the energy reserve of the hare.
Definition: hare_all.h:213
double m_TodaysEnergy
State variable - the amount of energy available today, can be in deficit.
Definition: hare_all.h:218
int m_StarvationDays
State variable - the number of consecutive days in negative energy balance.
Definition: hare_all.h:208
@ tohs_Foraging
Definition: hare_all.h:75
@ tohs_NextStage
Definition: hare_all.h:72
@ tohs_Dying
Definition: hare_all.h:79

References cfg_AdultMaxFat, cfg_juv_starve, cfg_juvenile_starvation_threshold, g_rand_uni, THare_Population_Manager::GetGrowthEfficiencyF(), THare_Population_Manager::GetGrowthEfficiencyP(), THare_Population_Manager::GetMaxDailyGrowthEnergyF(), THare_Population_Manager::GetMaxDailyGrowthEnergyP(), THare::m_Age, THare::m_fatReserve, THare::m_OurPopulationManager, THare::m_StarvationDays, THare::m_TodaysEnergy, THare::m_weight, ShouldMature(), tohs_Dying, tohs_Foraging, tohs_NextStage, CfgInt::value(), and CfgFloat::value().

Referenced by Step().

◆ st_Dispersal()

TTypeOfHareState Hare_Juvenile::st_Dispersal ( )
protectedvirtual

Juvenile Dispersal.

Makes a test of habitat quality (basically food) in 8 directions, then moves to the best one. This is basically a teleport move, so testing for barriers is not done. This will need to be added if it becomes a problem (e.g. hares appearing on islands they could not otherwise get too), however, this will also confer an extreme performance penalty!

Reimplemented from THare.

Reimplemented in Hare_Female.

2450 {
2451 #ifdef __DISPMORTALITY
2452  if (WasPredated()) return tohs_Dying;
2453 #endif
2454  // Now to make this a little more clever we need to test all 8 directions
2455  int ttx, tty;
2456  int tx=m_Location_x;
2457  int ty=m_Location_y;
2458  ttx=tx;
2459  tty=ty;
2460  double fv=0.0;
2461  double oldfv = -99999999.0;
2462  int dstart=random(8);
2463  int d2=0;
2464  for (int j=0; j<100; j++) {
2465  int dist=100+random(cfg_hare_max_dispersal.value());
2466  for (int d=dstart; d<8+dstart; d++) {
2467  // We need to avoid a bias movement now too
2468  int d1=d & 7; // 0-7
2469  Walking(dist, d1); // This modifies m_Location_x, m_Location_y
2470  // How much food here?
2473  if (oldfv<=fv) {
2474  oldfv=fv;
2475  ttx=m_Location_x;
2476  tty=m_Location_y;
2477  d2=dist;
2478  // The best we can ever get is 0.8 so we can speed things up by dropping out if we are close to this.
2479  if (fv>=0.75) {
2480  j=101;
2481  break;
2482  }
2483  }
2484  // Set the xy back before trying the next direction
2485  m_Location_x=tx;
2486  m_Location_y=ty;
2487  }
2488  }
2489  // Now do it for real
2490  // We need to update the density maps temporarily to stop all the animals responding to old data until the beginning of the next timestep
2492  m_Location_x = ttx;
2493  m_Location_y = tty;
2495  d2 *= 5; // Lets assume it is not a beeline, and 5x distance is needed to find the place.
2498  // Move the peg with us.
2499  //m_peg_x = m_Location_x; /** Testing whether the peg will be dragged anyway if we don't set this 31/7/2014 */
2500  //m_peg_y = m_Location_y;
2501  return tohs_Foraging;
2502 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
static CfgInt cfg_hare_max_dispersal("HARE_MAX_DISPERSAL", CFG_CUSTOM, 1000)
virtual bool WasPredated()
Test for mortality.
Definition: Hare_all.cpp:2645
double GetHareFoodQuality(int a_polygon)
Definition: Landscape.cpp:3403
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: landscape.h:1321
void AddHareDensity(int x, int y, Hare_Object a_type)
Density function - adds one to the density in the square containing by x,y. Each square is 256x256m i...
Definition: hare_all.h:641
void SubtractHareDensity(int x, int y, Hare_Object a_type)
Density function - subtracts one from the density in the square containing by x,y....
Definition: hare_all.h:646
int GetAdultDensity(int x, int y)
Density function - returns the density of adults in the square containing by x,y. Each square is 256x...
Definition: hare_all.h:681
void EnergyBalance(TTypeOfActivity a_activity, int dist)
Adjust energy balance for an activity.
Definition: Hare_THare.cpp:277
void TimeBudget(TTypeOfActivity a_activity, int dist)
Adjust time budger for an activity.
Definition: Hare_THare.cpp:314
static double * m_vegPalatability
Will hold and array of palatability for hare for each tov type. Most are 1, but unpalatable vegetatio...
Definition: hare_all.h:318
void Walking(int a_dist, int a_direction)
Walking.
Definition: Hare_THare.cpp:183
@ activity_Dispersal
Definition: hare_all.h:94

References activity_Dispersal, THare_Population_Manager::AddHareDensity(), cfg_hare_max_dispersal, THare::EnergyBalance(), THare_Population_Manager::GetAdultDensity(), Landscape::GetHareFoodQuality(), THare_Population_Manager::GetInterference(), TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, THare::m_OurPopulationManager, THare::m_Type, THare::m_vegPalatability, random(), THare_Population_Manager::SubtractHareDensity(), Landscape::SupplyPolyRef(), Landscape::SupplyVegType(), THare::TimeBudget(), tohs_Dying, tohs_Foraging, CfgInt::value(), THare::Walking(), and WasPredated().

Referenced by Hare_Female::st_Dispersal(), Step(), and Hare_Male::Step().

◆ st_Foraging()

TTypeOfHareState Hare_Juvenile::st_Foraging ( )
protected

Juvenile foraging.

Given the time we have then we need to feed, which will return an energy value obtained.

2386 {
2391  // We need to rest if there is no more time
2392  if (atime < 30) return tohs_Resting;
2393  // This version uses adult density for interference, other densities seem not to work so well
2394  //int hares=(m_OurPopulationManager->GetAdultDensity(m_Location_x, m_Location_y));
2395  //int hares=(m_OurPopulationManager->GetTotalDensity(m_Location_x, m_Location_y));
2396  int hares = 1;
2397 #ifdef __THRESHOLD_AD_DD
2398  if (hares<m_OurPopulationManager->m_HareThresholdDD) {
2399  hares=0;
2400  } else {
2402  }
2403 #endif
2404 #ifdef __THRESHOLD_DDJ
2405 // this section has been altered so many times it was not worth making it general - if it is used in release versions this can be implemented when we know how it should look - right now remember to change in code before compile-
2406  if (hares<6) hares=0;
2407  else hares*=hares;
2408 #endif
2409 
2410 #ifdef __SCALINGYOUNGDDM
2411  hares = (int) floor (0.5+(double)hares*cfg_JuvDDScale.value());
2412 #endif
2413 
2414  //interfer is between 1.0 and 0
2415  //double slope = 1.0+(cfg_AgeRelatedInterferenceScaling.value() * (1.0-(double(m_Age/365.0))));
2416  //double hs=hares*slope;
2417 #ifndef __DDEPMORT
2418  double inter = m_OurPopulationManager->GetInterference((int)(hares));
2419 #else
2420  double inter=1.0;
2421 #endif
2422  if ((inter<0.5) && (atime > 300)){
2423  if (g_rand_uni() > inter) // added to reduce rate of dispersal
2424  {
2425  //m_ActivityTime = (int)(atime / cfg_ForageRestingRatio.value());
2426  return tohs_Dispersal; // Added Sat 15th Dec 2007
2427  }
2428  }
2429  atime*= inter;
2430  int a_time = (int) atime;
2432  {
2433  m_TodaysEnergy = ForageP(a_time);
2434  }
2435  else
2436  {
2437  m_TodaysEnergy = Forage(a_time);
2438  }
2439  // We need to spend energy on foraging and associated movement
2440  //
2441  TimeBudget(activity_Foraging, (int)atime-a_time);
2442  return tohs_Resting;
2443 }
CfgFloat cfg_JuvDDScale("HARE_JUVSCALEDD", CFG_CUSTOM, 0.5)
CfgFloat cfg_ForageRestingRatio("HARE_FORAGERESTRATIO", CFG_CUSTOM, 0.67)
double Forage(int &time)
Foraging.
Definition: HareForagenPeg.cpp:54
double ForageP(int &time)
Foraging but also incorporating pesticide exposure.
Definition: HareForagenPeg.cpp:181
@ activity_Foraging
Definition: hare_all.h:92
@ tohs_Resting
Definition: hare_all.h:76
@ tohs_Dispersal
Definition: hare_all.h:74

References activity_Foraging, cfg_ForageRestingRatio, cfg_hare_pesticideresponse_on, cfg_JuvDDScale, THare::Forage(), THare::ForageP(), g_rand_uni, THare_Population_Manager::GetInterference(), THare::m_ActivityTime, THare_Population_Manager::m_HareThresholdDD, THare::m_OurPopulationManager, THare::m_TodaysEnergy, THare::TimeBudget(), tohs_Dispersal, tohs_Resting, CfgFloat::value(), and CfgBool::value().

Referenced by Step().

◆ st_NextStage()

void Hare_Juvenile::st_NextStage ( )
protected

Maturation to Hare_Male or Hare_Female.

This creates a Hare_Juvenile object via a call to create objects, then sets the flag for destruction of this object.

2608 {
2609  struct_Hare* sp;
2610  sp = new struct_Hare;
2611  sp->HM = m_OurPopulationManager;
2612  sp->L = m_OurLandscape;
2613  sp->x = m_Location_x;
2614  sp->y = m_Location_y;
2615  sp->weight = m_weight;
2616  sp->Mum = NULL;
2617  sp->age = m_Age;
2618  sp->RefNum = m_RefNum;
2619  // Sex ratio is set to be 50:50 at birth
2620  if ((m_RefNum & 0x01) == 0) // Male
2621  m_OurPopulationManager->CreateObjects(3,this,NULL,sp,1);
2622  else m_OurPopulationManager->CreateObjects(4,this,NULL,sp,1);
2623  // Clean-up
2624  m_CurrentStateNo=-1; // Destroys the object at the next opportunity
2626  delete sp;
2627 }
void CreateObjects(int ob_type, TAnimal *pvo, void *null, struct_Hare *data, int number)
Method used to create new hares.
Definition: Hare_all.cpp:928
int m_RefNum
Unique hare reference number, also functions as sex flag.
Definition: hare_all.h:265
Class used to pass hare information to CreateObjects.
Definition: hare_all.h:135
int RefNum
Definition: hare_all.h:143
int age
Definition: hare_all.h:139
Hare_Female * Mum
Definition: hare_all.h:142

References struct_Hare::age, THare_Population_Manager::CreateObjects(), struct_Hare::HM, struct_Hare::L, THare::m_Age, THare::m_CurrentHState, TALMaSSObject::m_CurrentStateNo, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, THare::m_OurPopulationManager, THare::m_RefNum, THare::m_weight, struct_Hare::Mum, struct_Hare::RefNum, tohs_DestroyObject, struct_Hare::weight, struct_Hare::x, and struct_Hare::y.

Referenced by Step().

◆ st_Resting()

TTypeOfHareState Hare_Juvenile::st_Resting ( )
protected

Juvenile Resting.

The hare spends some time resting (using time and a little energy)

2508 {
2509  EnergyBalance(activity_Resting, 0); // Just removes a days BMR
2511  return tohs_Developing;
2512 }
@ activity_Resting
Definition: hare_all.h:90
@ tohs_Developing
Definition: hare_all.h:73

References activity_Resting, THare::EnergyBalance(), THare::m_ActivityTime, THare::TimeBudget(), and tohs_Developing.

Referenced by Step().

◆ Step()

void Hare_Juvenile::Step ( void  )
virtual

Step for Hare_Juvenile.

As with all other ALMaSS animal objects, Step is where the primary state/transtion work is done

Reimplemented from THare.

Reimplemented in Hare_Female, and Hare_Male.

2317 {
2318  if (m_StepDone || m_CurrentStateNo == -1) return;
2319  switch (m_CurrentHState)
2320  {
2321  case tohs_InitialState: // Initial state
2323  break;
2324  case tohs_Dispersal:
2325  // Dispersal is risky therefore take a test again
2326  // Legal returns are:
2327  // tohs_Foraging
2328 #ifdef __DISPERSALDDM
2330  ON_Dead();
2331  m_StepDone=true; // We need to skip the step code, we are dead
2332  return;
2333  }
2334 #endif
2336  break;
2337  case tohs_Foraging:
2338  // Legal returns are:
2339  // tohs_JResting
2341  break;
2342  case tohs_Resting:
2343  // Legal returns are:
2344  // tohs_Developing
2346  break;
2347  case tohs_Developing:
2348  // Legal returns are:
2349  // tohs_Dispersal
2350  // tohs_NextStage
2351  // tohs_Resting
2354  break;
2355  case tohs_NextStage:
2356  // Legal returns are:
2357  // NONE
2358  st_NextStage();
2359  m_StepDone=true;
2360  break;
2361  case tohs_Dying:
2362  ON_Dead();
2363  m_StepDone=true;
2364  break;
2365  default:
2366  m_OurLandscape->Warn("Hare_Juvenile::Step - unknown state",NULL);
2367  exit(1);
2368  }
2369 }
static CfgFloat cfg_hare_juvenile_predation("HARE_JUVENILE_PREDATION", CFG_CUSTOM, 0.0016)
TTypeOfHareState st_Developing()
The development code for Hare_Juvenile.
Definition: Hare_all.cpp:2522
TTypeOfHareState st_Resting()
Juvenile Resting.
Definition: Hare_all.cpp:2507
void st_NextStage()
Maturation to Hare_Male or Hare_Female.
Definition: Hare_all.cpp:2607
TTypeOfHareState st_Dispersal()
Juvenile Dispersal.
Definition: Hare_all.cpp:2449
TTypeOfHareState st_Foraging()
Juvenile foraging.
Definition: Hare_all.cpp:2385
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
@ tohs_InitialState
Definition: hare_all.h:71

References cfg_hare_juvenile_predation, g_rand_uni, THare::m_CurrentHState, TALMaSSObject::m_CurrentStateNo, TAnimal::m_OurLandscape, TALMaSSObject::m_StepDone, ON_Dead(), st_Developing(), st_Dispersal(), st_Foraging(), st_NextStage(), st_Resting(), tohs_Developing, tohs_Dispersal, tohs_Dying, tohs_Foraging, tohs_InitialState, tohs_NextStage, tohs_Resting, CfgFloat::value(), and Landscape::Warn().

◆ WasPredated()

bool Hare_Juvenile::WasPredated ( )
protectedvirtual

Test for mortality.

Reimplemented from THare.

2645  {
2646  if (g_rand_uni()<m_OurPopulationManager->m_JuvMortRate) return true;
2647  return false;
2648 }

References g_rand_uni, THare_Population_Manager::m_JuvMortRate, and THare::m_OurPopulationManager.

Referenced by Hare_Male::BeginStep(), Hare_Female::BeginStep(), and st_Dispersal().


The documentation for this class was generated from the following files: